<?php
class Frame_Controller_App extends Frame_Controller_Base{

    public function init(){
        if(!$this->isLogin())
            return $this->redirect(MONK::_url('home/login'));
        $this->assign('my',$this->user);
        if(!$this->teamFilter())
            return $this->redirect(MONK::_url('team/opt'));
        $this->assign('team_id',$this->team_id);
        $this->assign('my_teams',$this->user_teams);
        $this->assign('team_creater_id',$this->team_creater_id);
        parent::init();
    }

    //应用首页
    public function actionIndex(){
        //获取应用库列表
        $model_app = MONK::getSingleton('Frame_Model_App');
        $apps = $model_app->get_opened_apps($this->team_id);
        $this->assign('apps',$apps);
        $app_categorys = $model_app->get_app_category();
        $this->assign('app_categorys',$app_categorys);
        return $this->render();
    }

    //应用详情页面
    public function actionOne(){
        $this->_setType(array('app_id'=>PARAM_STRING));
        $app_id = $this->_get('app_id');
        $model_app = MONK::getSingleton('Frame_Model_App');
        $app = $model_app->get_by_id_open($app_id);
        if(empty($app))
            return $this->redirect(MONK::_url('home/404'));
        $info = array();
        if(!empty($app['app_info'])){
            $info = unserialize($app['app_info']);
        }
        /*
        $info2 = serialize(array(
            array('title'=>'首先进入的是项目列表','screen_shot'=>'5y5d2yddyd2ydaey.jpg'),
            array('title'=>'可以看到自己的团队成员','screen_shot'=>'5y2eye2yesysdy42.jpg'),
            array('title'=>'进入项目以后有任务列表等','screen_shot'=>'7dh4sy4fydywdyd3.jpg'),
            array('title'=>'任务列表下所有任务，包括已完成和未完成','screen_shot'=>'55fdayweff35dfys.jpg'),
            array('title'=>'项目中上传的文件','screen_shot'=>'jylsye4dy3k36lsy.jpg'),
        ));
        echo $info2;
        */
        $app_category = $model_app->get_app_category_by_id($app['ac_id']);
        $this->assign('app',$app);
        $this->assign('info',$info);
        $this->assign('app_category',$app_category?$app_category['ac_name']:'无分类');
        return $this->render();
    }
}
